package com.vn.gofriends.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.vn.gofriends.R;
import com.vn.gofriends.item.City;

public class MyTripsAdapter extends ArrayAdapter<City> {

	Context context;
	List<City> cities;
	int res;

	public MyTripsAdapter(Context context, int resource,
			List<City> cities) {
		super(context, resource, cities);
		this.context = context;
		this.cities = cities;
		this.res = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if (view == null) {
			view = ((LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(res, parent, false);
		}
		City c = cities.get(position);
		if (c != null) {
			TextView txtNameTrip = (TextView) view
					.findViewById(R.id.txtNamePlace);
			txtNameTrip.setText(c.getCityName());
		}
		return view;
	}
}
